<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <base href="/">
    <meta charset="UTF-8">
    <title>管理员登录</title>
    <style>
        .container {
            width: 300px;
            margin: 100px auto;
            padding: 20px;
            border: 1px solid #ddd;
            border-radius: 5px;
        }
        .form-group {
            margin-bottom: 15px;
        }
        .form-group label {
            display: block;
            margin-bottom: 5px;
        }
        .form-group input {
            width: 100%;
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }
        .btn {
            width: 100%;
            padding: 10px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        .btn:hover {
            background-color: #45a049;
        }
        .link {
            text-align: center;
            margin-top: 10px;
        }
    </style>
</head>
<body>
<div class="container">
    <h2 style="text-align: center;">管理员登录</h2>
    <form action="/login" method="post">
        <div class="form-group">
            <label for="username">用户名：</label>
            <input type="text" id="username" name="username" required>
        </div>
        <div class="form-group">
            <label for="password">密码：</label>
            <input type="password" id="password" name="password" required>
        </div>
        <button type="button" class="btn">登录</button>
    </form>
</div>
<script src="layui/layui.all.js"></script>
<script>
    const $=layui.$;
    const layer=layui.layer;
    $(".btn").click(function(){
        //验证数据
        let username=$("[name='username']").val();
        let password=$("[name='password']").val();
        let reg=/^[a-zA-Z0-9]{6,16}$/;
        if(reg.test(username)&&reg.test(password)){
            $.ajax({
                url:'system/dologin1',
                data:{username:username,password:password},
                success:function(result){
                    if(result.code==200){
                        layer.msg("登陆成功",{icon:1});
                        setTimeout(function(){
                            location.href="system/index";
                        },1800)
                    }else{
                        layer.msg(result.msg);
                    }
                }
            });
        }else{
            layer.msg("用户名和密码必须是6-16位字符数字");
            return;
        }
    });
</script>
</body>
</html>